<template>
  <div class="home-echarts-bar-box">
    <el-scrollbar style="height: 100%">
      <div
        v-for="(item,index) in echartsList"
        :key="index"
        class="home-echarts-bar"
        :style="'z-index:' + (isShow[index]?3:0) "
      >
        <div :class="{'on':isShow[index]}" @click="show('open',index)" class="dash-box">
          <i
            v-if="isShow[index]"
            class="el-icon-circle-close-outline"
            @click.stop="show('close',index)"
          ></i>
          <div class="mask" @click.stop="show('close',index)"></div>
          <div class="title">{{ item.title }}</div>
          <div class="echart">
            <div class="echart-inner">
              <echarts :data="item.data" class="echarts-item"></echarts>
                 <!--在这个 echarts 组件里 item.data 就是配置   data是参数项 -->
            </div>
          </div>
        </div>
      </div>
    </el-scrollbar>
  </div>
</template>

<script>
import Echarts from "@/components/echarts/index";

import { overview4, overview5, overview6 } from "@/api/dashboard"; // 不同模块的api 分开放，
// import * as services from "@/api/dashboard";
export default {
  name: "SalesRecovery",
  components: {
    Echarts
  },
  data() {
    return {
      isShow: [],
      echartsList: ['','','']// 初始化定义一个数组长度为3的数组
    };
  },

  mounted() {
    // 处理拿到的数据
    const that = this;
    var newArray = [];
    // 这里放进去了1个，其他接口一样这样
    overview4({}).then(res => {
      //销售回收率汇总
      //this.echartsList.push(res.data);
      this.echartsList[0] = res.data;
     //console.log(res.data);
    });
    overview5({}).then(res => {
      //客服受理汇总
      //this.echartsList.push(res.data);
      this.echartsList[1] = res.data;
      //console.log(res.data);
    });
    overview6({}).then(res => {
      //设备运行正常率
      //this.echartsList.push(res.data);
      this.echartsList[2] = res.data;
      //console.log(res.data);
    });
    // 这里放进去了1个，其他接口一样这样
    overview4({}).then(res => {
      //销售回收率汇总
      that.echartsList.push(res.data);
      overview5({}).then(res => {
        //设备运行正常率
        that.echartsList.push(res.data);
        overview6({}).then(res => {
          //客服受理汇总
          that.echartsList.push(res.data);
        });
      });

    });



    console.log(this.echartsList)
    // let water1 = new Promise((resolve, reject) => {
    //   overview4({}).then(res => {
    //     //销售回收率汇总
    //     if (res.code == "200") {
    //       resolve(res.data);
    //     } else {
    //       reject();
    //     }
    //   });
    // });
    // let water2 = new Promise((resolve, reject) => {
    //   overview5({}).then(res => {
    //     //销售回收率汇总
    //     if (res.code == "200") {
    //       resolve(res.data);
    //     } else {
    //       reject();
    //     }
    //   });
    // });
    // let water3 = new Promise((resolve, reject) => {
    //   overview6({}).then(res => {
    //     //销售回收率汇总
    //     if (res.code == "200") {
    //       resolve(res.data);
    //     } else {
    //       reject();
    //     }
    //   });
    // });
    // Promise.all([overview4, overview5, overview6]).then(items => {
    //   this.echartsList = [...items[0], ...items[1], ...items[2]];
    // });
  },
  methods: {
    getData() {
      overview2().then(res => {
        //console.log(res + "2222");
        // 处理拿到的数据
      });
    },
    selTime() {
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      setTimeout(() => {
        loading.close();
      }, 800);
    },
    show(e, index) {
      //console.log(e, index);
      const th = this;
      function todo(isShow) {
        th.$set(th.isShow, index, isShow);
        //console.log(th.isShow);
      }

      if (e === "open" && th.isShow[index] === true) {
        return;
      }
      todo(e === "open");
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.map {
  position: absolute;
  top: 0.5rem;
  left: calc(26vw + 0.5rem);
  right: calc(26vw + 0.5rem);
  bottom: calc(23% + 0.5rem);
  overflow: hidden;
  background: url("../img/pic_Map_main.png") no-repeat center;
  background-size: auto 110%;
  span {
    font-size: 1.3em;
    margin: 0 5px;
  }
  .list {
    position: absolute;
    background: rgba(0, 0, 0, 0.1);
    font-size: 0.8rem;
    padding: 0.5rem 1.5rem 0.5rem 2rem;
    line-height: 1.3;
    .title {
      line-height: 1.4;
      margin-bottom: 0.2rem;
      font-size: 1rem;
      color: #00ccff;
      &:before {
        content: "";
        position: absolute;
        width: 16px;
        height: 16px;
        border-radius: 100%;
        border: 2px solid #cc66ff;
        background: #6600cc;
        top: calc(1.2rem - 8px);
        left: 0.7rem;
      }
      &.title-2:before {
        content: "";
        position: absolute;
        width: 16px;
        height: 16px;
        border-radius: 100%;
        border: 2px solid #ff3333;
        background: #663300;
        top: calc(1.2rem - 8px);
        left: 0.7rem;
      }
    }
    .color {
      color: #00ccff;
    }
    i,
    b {
      width: 1px;
      height: 20px;
      position: absolute;
      background: #00ccff;
      &.l {
        left: 0;
      }
      &.t {
        top: 0;
      }
      &.r {
        right: 0;
      }
      &.b {
        bottom: 0;
      }
    }
    b {
      height: 1px;
      width: 20px;
    }
  }
}
.home-echarts-bar-box {
  position: absolute;
  width: 26vw;
  right: 0.5rem;
  top: 0.5rem;
  bottom: 0.5rem;
  overflow-x: auto;
  .home-echarts-bar {
    cursor: pointer;
    z-index: 2;
    height: 28vh;
    position: relative;
    margin-bottom: 1rem;
    .dash-box {
      height: 100%;
      .title {
        height: 2rem;
        text-align: center;
        line-height: 2rem;
      }
      .echart {
        height: calc(100% - 2rem);
        padding: 0.5rem;
        &-inner {
          height: 235.714%;
          width: 230.77%;
          transform: scale(0.433333, 0.42424242);
          transform-origin: 0 0;
        }
      }
      &.on {
        position: fixed;
        top: 15vh;
        transform: none !important;
        width: 60vw;
        height: 66vh;
        right: 50%;
        margin-bottom: -27vh;
        margin-right: -30vw;
        border-radius: 2px;
        border: 2px solid rgba(27, 164, 226, 0.85);
        background: rgba(24, 10, 67, 0.95);
        z-index: 4;
        &:before {
          opacity: 0;
          transition: opacity 0.3s;
        }
        .mask {
          display: block;
        }
        .title {
          height: 4rem;
          line-height: 4rem;
          font-size: 1.5rem;
        }
        transform: none !important;
        width: 60vw;
        height: 66vh;
        .echart {
          &-inner {
            height: 100%;
            width: 100%;
            transform: none;
          }
        }
      }
      .mask {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.1);
        z-index: -1;
      }
    }
    .el-icon-circle-close-outline {
      position: absolute;
      top: -16px;
      right: -16px;
      font-size: 24px;
      width: 32px;
      height: 32px;
      line-height: 32px;
      text-align: center;
      color: #dddddd;
      &:hover {
        color: #fff;
      }
      &:after {
        content: "";
        position: absolute;
        width: 20px;
        height: 20px;
        border-radius: 100%;
        background: rgba(24, 10, 67, 0.95);
        top: 6px;
        left: 6px;
        z-index: -1;
      }
    }
  }
}

.echarts-item {
  &-0 {
    bottom: calc(66% + 0.5rem + 5vh);
  }
  &-1 {
    bottom: calc(33% + 0.5rem + 2.5vh);
  }
  &-2 {
    bottom: 0.5rem;
  }
}

.indicator {
  position: absolute;
  left: 0.5rem;
  top: -1.5rem;
  width: 26vw;
  height: 65%;
  &-title {
    display: flex;
    span {
      font-size: 1rem;
      line-height: 1.2rem;
      padding: 0.5rem 1.5rem 0.5rem 0.5rem;
      background: url("../img/Icon_Irregularrectangle_head.png") no-repeat
        center left;
      background-size: 100% 100%;
    }
  }
  .value-0 {
    color: #ff33ff;
  }
  .value-1 {
    color: #33ff33;
  }
  .value-2 {
    color: #ffcc33;
  }
  &-month {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.5rem;
    .month {
      width: calc(50% - 50px);
    }
  }
  &-main {
    height: calc(100% - 7rem);
    > div {
      height: 25%;
      padding-top: 0.3rem;
      position: relative;
      .title {
        font-size: 0.825rem;
        height: 25%;
        display: flex;
        align-items: center;
        color: #00ffff;
        padding-left: 0.8rem;
      }
      .main {
        height: 70%;
        display: flex;
        align-items: center;
        padding: 0.3rem 0;
        li {
          height: 100%;
          width: calc(100% / 3 - 0.666667px);
          position: relative;
          margin-left: 1px;
          &:after {
            content: "";
            display: block;
            position: absolute;
            width: 1px;
            top: 20%;
            right: -1px;
            height: 60%;
            background: #00beea;
          }
          &:last-child:after {
            content: none;
          }
          .label {
            height: 45%;
            display: flex;
            justify-content: center;
            font-size: 0.75rem;
          }
          .value {
            height: 65%;
            display: flex;
            justify-content: center;
            font-size: 1.5rem;
          }
        }
      }
      &:after {
        content: "";
        display: block;
        height: 1px;
        width: 84%;
        position: absolute;
        background: #00ccff;
        left: 8%;
        bottom: -1px;
      }
      &:last-child:after {
        content: none;
      }
    }
  }
}

.quality {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  width: 26vw;
  height: 36%;
  &-title {
    font-size: 1rem;
    line-height: 2.4rem;
    padding-left: 0.5rem;
    background: #192790;
  }
  &-main {
    width: 133.3333%;
    transform: scale(0.75, 0.75);
    height: calc(133.3333% - 3.4rem);
    transform-origin: 0 0;
  }
}

.marketing {
  padding: 1rem;
  position: absolute;
  left: 28.5%;
  bottom: 0.5rem;
  width: 43%;
  height: 23%;
  display: flex;
  .marketing-item {
    width: 50%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .left {
      margin-right: 0.5rem;
      width: 14vh;
      height: 100%;
    }
    .right {
      padding-bottom: 1.2rem;
    }
  }
}

.dash-box {
  border: 1.2px solid #00ccff;
  background: rgba(0, 0, 255, 0.15);
  box-shadow: 0 0 0.5rem #1800ff;
}

.echarts-item {
  height: 100%;
  .echarts-title {
    text-align: center;
    font-size: 1.3rem;
    height: 2.6rem;
    line-height: 1.8rem;
  }
}

.topList {
  display: flex;
  li {
    width: 33.33%;
    color: #00ccff;
    font-size: 1.1rem;
    span {
      font-size: 1.3rem;
      color: #33ff33;
    }
    &:last-child span {
      color: #ffcc33;
    }
    &:first-child span {
      color: #ff33ff;
    }
  }
}
</style>
<style rel="stylesheet/scss" lang="scss">
.month {
  .el-input__inner {
    padding-right: 0 !important;
  }
}

.el-table thead.is-group th,
.el-table,
.el-table__expanded-cell,
.el-table th,
.el-table tr {
  background: transparent;
}

.el-table,
.el-table thead {
  font-size: 1.2rem;
  color: #fff;
  text-align: center;
}

.el-table thead {
  color: #e78a20;
  text-align: center;
}

.el-table .cell {
  text-align: center;
}

.el-table--enable-row-hover .el-table__body tr:hover > td {
  background: rgba(255, 255, 255, 0.15);
}

.el-progress--circle .el-progress__text {
  font-size: 2rem !important;
  color: #ff33ff;
}
</style>
